package com.liugai.tool.token;

import java.util.Date;

public class TokenTicket {
    private Long id;
    private Date expDate;
    private Date iatDate;
    private String token; //经过jwt生成，然后md5加密后的token
    public TokenTicket() {
    }

    public TokenTicket(Long id, Date expDate, Date iatDate, String token) {
        this.id = id;
        this.expDate = expDate;
        this.iatDate = iatDate;
        this.token = token;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getExpDate() {
        return expDate;
    }

    public void setExpDate(Date expDate) {
        this.expDate = expDate;
    }

    public Date getIatDate() {
        return iatDate;
    }

    public void setIatDate(Date iatDate) {
        this.iatDate = iatDate;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public boolean isAvailable() {

        if (this.expDate == null || this.iatDate == null || this.id == 0) {
            return false;
        }
        Date date = new Date();
        long timeIntervar = this.expDate.getTime() - date.getTime();
        if (timeIntervar<1) {
            return false;
        }
        return true;
    }


    @Override
    public String toString() {
        return "TokenDecryptData{" +
                "token =" + token + '}';
    }
}
